import utils from './utils.js'
process.stdin.setEncoding('utf-8')

process.stdin.on('data', req => {
  const jsonrpc = JSON.parse(req)
  const reqMethod = jsonrpc.method
  const reqParams = jsonrpc.params

  const result = utils[reqMethod](reqParams)

  const res = {
    "jsonrpc": 2.0,
    "data": result,
    "id": jsonrpc.id
  }

  process.stdout.write(`${JSON.stringify(res)}\n`)
})